//
//  MonsterPropertyView.cpp
//  FruitCrush
//
//  Created by gaoyu on 15/8/7.
//
//

#include "MonsterPropertyView.h"

#define ICON_HEIGHT  25

MonsterPropertyView::MonsterPropertyView()
:index(0)
{
}

bool MonsterPropertyView::init()
{
    if (!Layer::init()) {
        return false;
    }
    
    return true;
}

void MonsterPropertyView::addPropertyState(int type)
{
    auto cache = SpriteFrameCache::getInstance();
    cache->addSpriteFramesWithFile("Monsters.plist");
    
    auto stateIcon = Sprite::createWithSpriteFrameName(getFileName(type).getCString());
    stateIcon->setAnchorPoint(Vec2::ZERO);
    stateIcon->setPosition(Point(0,ICON_HEIGHT*index));
    this->addChild(stateIcon);
    index++;
}

__String MonsterPropertyView::getFileName(int type)
{
    switch (type) {
        case MonsterPropertyShowTypeSwordWeak: return __String("SwordWeak.png");
        case MonsterPropertySHowTypeSwordImmune: return __String("SwordImmune.png");
        case MonsterPropertyShowTypeArrowWeak: return __String("ArrowWeak.png");
        case MonsterPropertySHowTypeArrowImmune: return __String("ArrowImmune.png");
        case MonsterPropertyShowTypeFireWeak: return __String("FireWeak.png");
        case MonsterPropertySHowTypeFireImmune: return __String("FireImmune.png");
        case MonsterPropertyShowTypeLightWeak: return __String("LightWeak.png");
        case MonsterPropertySHowTypeLightImmune: return __String("LightImmune.png");

    }
    return NULL;
}